import { ref, Ref } from 'vue';

export default function useDialog(defValue = false) {
  const dialogVisible: Ref<boolean> = ref(defValue);
  const dialogTitle = ref('');
  const dialogMode = ref(0);
  const dialogModeMap = {0: '查看', 1: '新增', 2: '编辑'};
  const dialogIconMap = {0: 'ep:info-filled', 1: 'ep:upload-filled', 2: 'ep:edit-pen'};
  const setDialogVisible = (value: boolean) => {
    dialogVisible.value = value;
  };
  const toggleDialogVisible = () => {
    dialogVisible.value = !dialogVisible.value;
  };

  const setDialogTitle = (value: string) => {
    dialogTitle.value = value;
  };

  const setDialogMode = (value: number) => {
    dialogMode.value = value;
  };

  return {dialogVisible, dialogTitle, dialogMode, dialogModeMap, dialogIconMap, setDialogVisible, setDialogTitle, setDialogMode, toggleDialogVisible};
}
